package com.cskaoyan.service;

import com.cskaoyan.bean.user.FootPrint;
import com.cskaoyan.bean.user.FootPrintExample;
import com.cskaoyan.mapper.FootPrintMapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author dww
 */

@Service
public class FootPrintServiceImpl implements FootPrintService {
    @Autowired
    private FootPrintMapper footPrintMapper;

    public List<FootPrint> getFootPrintList(Integer page, Integer limit, String sort, String order, Integer userId, Integer goodsId) {
        PageHelper.startPage(page, limit, sort + " " + order);
        FootPrintExample example = new FootPrintExample();
        FootPrintExample.Criteria criteria = example.createCriteria();
        if (userId != null)
            criteria.andUserIdEqualTo(userId);
        if (goodsId != null)
            criteria.andGoodsIdEqualTo(goodsId);
        return footPrintMapper.selectByExample(example);
    }
}
